import { Entity, PrimaryGeneratedColumn, Column, CreateDateColumn, UpdateDateColumn, Index } from 'typeorm';
import { BaseEntity } from './base.entity';

@Entity({ name: 'categories' })
export class Categories extends BaseEntity {
    @Column({ 
        name: 'sort_order', 
        default: 0 ,
        comment:"排序"
    })
    @Index('idx_sort_order') // 为排序字段创建索引
    sortOrder!: number;

    @Column({
        name: 'name',
        type: 'varchar',
        length: 50,
        nullable: false,
        comment: '分类名称'
    })
    name!: string;

    @Column({
        name: 'slug',
        type: 'varchar',
        length: 50,
        nullable: false,
        comment: '分类别名(URL友好)'
    })
    @Index('uk_slug', { unique: true }) // 对应 UNIQUE KEY
    slug!: string;
}
